<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form  class="layui-form" onsubmit="return false">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>产品名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cpName" name="cpName" required="" lay-verify="cpName"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请您输入添加的产品名
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        <span class="x-red">*</span>产品功能
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cpGongNeng" name="cpGongNeng" required="" lay-verify="cpGongNeng"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入产品的功能
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>销售价格
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cpShouJia" name="cpShouJia" required="" lay-verify="cpShouJia"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入销售的价格
                    </div>
                </div>
                
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>品牌
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cpPinPai" name="cpPinPai" required="" lay-verify="cpPinPai"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入品牌
                    </div>
                </div>
                
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>输入图片路径
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cpLoGo" name="cpLoGo" required="" lay-verify="cpLoGo"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入图片路径
                    </div>
                </div>
                
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>分类Id
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cpFenLei" name="cpFenLei" required="" lay-verify="cpFenLei"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入分类的Id
                    </div>
                </div>
                
               
                </div>
                
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button onclick="addProduct()" class="layui-btn" lay-filter="add" >
                        增加
                    </button>
                </div>
            </form>
        </div>
        <script src="./lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="./js/x-layui.js" charset="utf-8">
        </script>
        <script>
        var $=null;
        var form = null;
        var layer=null;
        
        
        
            layui.use(['form','layer'], function(){
              $ = layui.jquery;
              form = layui.form;
              layer = layui.layer;
   
              $(function(){
            	  
            	  addProduct();
              }); 
              
            });
            
           
            
            
            function addProduct(){
            	//获取文本框内的值
            	var cpName = $("#cpName").val();
            	if (cpName == null || cpName == "") {
					return false;//代表停止代码
				}
            	var cpGongNeng = $("#cpGongNeng").val();
            	if (cpGongNeng == null || cpGongNeng == "") {
					return false;//代表停止代码
				}
            	var cpShouJia = $("#cpShouJia").val();
            	if (cpShouJia == null || cpShouJia == "") {
					return false;//代表停止代码
				}
            	var cpPinPai = $("#cpPinPai").val();
            	if (cpPinPai == null || cpPinPai == "") {
					return false;//代表停止代码
				}
            	var cpLoGo = $("#cpLoGo").val();
            	if (cpLoGo == null || cpLoGo == "") {
					return false;//代表停止代码
				}
            	var cpFenLei = $("#cpFenLei").val();
            	if (cpFenLei == null || cpFenLei == "") {
					return false;//代表停止代码
				}
            	
            	
            	
            	$.post("../adminProduct?reqName=addProducts",{
            		chanPinName:cpName,
            	chanPinGongNeng:cpGongNeng,
            	chanPinShouJia:cpShouJia,
            	shangPinPinPai:cpPinPai,
            	chanPinXiangQingLoGo:cpLoGo,
            	xiangQingWaiJianId:cpFenLei
            		
            		
            		
            	},function(res){
            		
            		if (res.success) {
						layer.msg(res.message);
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);//关闭当前页
						//当关闭成功后,重新调用查询方法
						parent.selProducts();
					} else {
						layer.msg(res.message);
					}
            		
            	},"json");
            	
            }
            
        </script>
        
    </body>

</html>